package com.pyramid.order;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.pyramid.R;
import com.pyramid.main.DefaultActivity;
import com.pyramid.tools.Tools;

public class OrderThActivity extends DefaultActivity {
	AlertDialog alertDialog;
	View bodyView;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		init();
	}

	private void init() {
		// top left button
		butTopLeft.setVisibility(View.VISIBLE);
		butTopLeft.setBackgroundResource(R.drawable.back);
		butTopLeft.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		// top right button
		butTopRight.setVisibility(View.VISIBLE);
		butTopRight.setBackgroundResource(R.drawable.home);
		butTopRight.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		// bottom left button
		butBotLeft.setVisibility(View.VISIBLE);
		butBotLeft.setBackgroundResource(R.drawable.calculate);
		// arrow
		imageArrow.setVisibility(View.VISIBLE);
		// title
		imageTitle.setBackgroundResource(R.drawable.title_beijing);
		imageTitle.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				alertDialog = new AlertDialog.Builder(OrderThActivity.this)
						.create();
				alertDialog.setView(getLayoutInflater().inflate(
						R.layout.order_titledialog, null));
				alertDialog.show();
				Tools.dialogwidth(alertDialog, OrderThActivity.this);

				TextView txtOrder1 = (TextView) alertDialog
						.findViewById(R.id.txt_ordertitle_one);
				txtOrder1.setOnClickListener(new OnClickListener() {

					public void onClick(View v) {
						startActivity(new Intent(OrderThActivity.this,
								OrderOneActivity.class));
						finish();
						alertDialog.cancel();
					}
				});
				TextView txtOrder2 = (TextView) alertDialog
						.findViewById(R.id.txt_ordertitle_two);
				txtOrder2.setOnClickListener(new OnClickListener() {

					public void onClick(View v) {
						startActivity(new Intent(OrderThActivity.this,
								OrderTwoActivity.class));
						finish();
						alertDialog.cancel();
					}
				});
				TextView txtOrder3 = (TextView) alertDialog
						.findViewById(R.id.txt_ordertitle_th);
				txtOrder3.setOnClickListener(new OnClickListener() {

					public void onClick(View v) {
						alertDialog.cancel();
					}
				});
			}
		});
	}
}
